<template>
    <el-row class="user-info-form add-property-detail" type="flex" justify="center">
        <el-col class="asset-info-form">
            <el-form label-width="150px" :model="assetInfoForm" :rules="assetInfoFormRules" ref="assetInfoForm" @submit.native.prevent>
                <el-form-item label="状态：" prop="status">
                    <el-radio-group v-model="assetInfoForm.status">
                        <el-radio label="0">在用</el-radio>
                        <el-radio label="1">停用</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item label="型号：" prop="model">
                    <el-input v-model="assetInfoForm.model" auto-complete="off" placeholder="请输入型号"></el-input>
                </el-form-item>
                <el-form-item label="品牌：" prop="brand">
                    <el-input v-model="assetInfoForm.brand" auto-complete="off" placeholder="请输入品牌名称"></el-input>
                </el-form-item>
                <el-form-item label="生产厂家：" prop="producerName">
                    <el-input v-model="assetInfoForm.producerName" auto-complete="off" placeholder="请输入生产厂家名称"></el-input>
                </el-form-item>
                <el-form-item label="生产日期：" prop="productionTimeStr">
                    <el-date-picker
                        v-model="assetInfoForm.productionTimeStr"
                        type="datetime"
                        placeholder="选择日期时间"
                        value-format="yyyy-MM-dd HH:mm:ss">
                    </el-date-picker>
                </el-form-item>
                <el-form-item v-show="assetInfoForm.productionTimeStr" label="保质期：">
                    <el-input-number v-model="assetInfoForm.yearNum" size="medium" :precision="0" :min="0" style="width: 110px"></el-input-number>
                    <span>年</span>
                    <el-input-number v-model="assetInfoForm.monthNum" size="medium" :precision="0" :min="0" style="width: 110px"></el-input-number>
                    <span>月</span>
                    <el-input-number v-model="assetInfoForm.dayNum" size="medium" :precision="0" :min="0" style="width: 110px"></el-input-number>
                    <span>日</span>
                </el-form-item>
                <el-form-item label-width="0" class="verifyidentity-button">
                    <el-button @click.stop="closeModifyingAsset" round>取消</el-button>
                    <el-button type="primary" @click="saveAsset('assetInfoForm')" round>保存</el-button>
                </el-form-item>
            </el-form>
        </el-col>
    </el-row>
</template>
<script>
import { updateBatchAssetInfo } from '@/api/fcf'
export default {
    props:{
        closeModifyingAsset: {
            type: Function,
            required: true
        },
        organizationId:{
            type:Number,
            required: true
        },
        multipleSelection:{
            type:Array,
            required: true
        }
    },
    data(){
        return{
            assetInfoFormRules: {
                status: [
                    { required: true, message: '请选择状态', trigger: 'change' }
                ],
            },
            assetInfoForm: {
                status: '0',
                model: '',
                brand: '',
                producerName: '',
                productionTimeStr:'',
                yearNum: '', // 年限
                monthNum: '', // 月限
                dayNum: '', // 日限
            },
        }
    },
    created(){
    },
    methods:{
        // 保存
        saveAsset(){
            let _this = this
            let arr = []
            for(let i in this.multipleSelection){
                arr.push(this.multipleSelection[i].id)
            }
            let params = {
                ids:arr.join(),
                status:_this.assetInfoForm.status,
                model:_this.assetInfoForm.model.toString(),
                brand:_this.assetInfoForm.brand.toString(),
                producerName:_this.assetInfoForm.producerName.toString(),
                yearNum:_this.assetInfoForm.yearNum,
                monthNum:_this.assetInfoForm.monthNum,
                dayNum:_this.assetInfoForm.dayNum,
                productionTime:_this.assetInfoForm.productionTimeStr,
            }
            updateBatchAssetInfo(params).then(res=>{
                if(res.status == 200){
                    _this.$message({
                        message: "修改成功！",
                        type: "success"
                    });
                    _this.closeModifyingAsset(true)
                }else{
                    _this.$message({
                        message: res.info,
                        type: "warning"
                    });
                }
            })
        }
    }
}
</script>
<style lang="sass" scoped>

</style>